package main.dao;

import java.util.List;

import main.entity.Boy;
import main.entity.Girl;

import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;

public interface GirlRepository extends JpaRepository<Girl, Integer>{

	public Page<Girl> findByBoyFriend_Name(String name,Pageable pageable);
	
	public List<Girl> findByBoyFriend(Boy boy);
	
	public List<Girl> findByBoyFriend_Address(String address);
	
	@Query(value="select girl from Girl girl,Boy boy,Father father where girl.boyFriend=boy.id and girl.father=father.id and boy.name=?1 and father.id=?2")
	public Page<Girl> findByParams(String name,Integer id,Pageable pageable);
	
	@Query("select girl from Girl girl , Boy boy where girl.boyFriend=boy.id and boy.name=?1 order by girl.id desc")
	public Page<Girl> findPageByParam(String name,Pageable pageable); 
}
